package com.naiterui.ehp.bs.pharmacist.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.*;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 药师基本信息
 */
@Builder
@Data
@Entity
@Table(name = "pharmacist")
@AllArgsConstructor
@NoArgsConstructor
public class Pharmacist implements Serializable {

    private static final long serialVersionUID = -7082311219325827440L;

    public final static Integer ACCOUNT_STATUS_NORMAL = 0;

    public final static Integer STATUS_NOT_ACTIVE = 0;
    public final static Integer STATUS_ACTIVE = 1;

    public final static Integer AUTH_STATUS_PENDING = 0;
    public final static Integer AUTH_STATUS_PASS = 1;
    public final static Integer AUTH_STATUS_NOTPASS = 2;

    /*
     * 性别 0：未知，1：男，2：女
     */
    /**
     * 女：<code>GENDER_FEMALE</code>
     */
    public static final int GENDER_FEMALE = 2;
    /**
     * 男：<code>GENDER_MALE</code>
     */
    public static final int GENDER_MALE = 1;
    /**
     * 未知：<code>GENDER_UNKNOWN</code>
     */
    public static final int GENDER_UNKNOWN = 0;


    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Long id;

    /**
     * 药师姓名
     */
    @Column(name = "name")
    private String name;

    /**
     * 性别
     */
    @Column(name = "gender")
    private Integer gender;

    /**
     * 民族
     */
    @Column(name = "ethnicity")
    private String ethnicity;

    /**
     * 电话
     */
    @Column(name = "phone")
    private String phone;

    /**
     * 身份证号
     */
    @Column(name = "card_no")
    private String cardNo;

    /**
     * 药师资格证编号
     */
    @Column(name = "license_no")
    private String licenseNo;

    /**
     * 专业特长
     */
    @Column(name = "skill")
    private String skill;

    /**
     * 职称(1:药士, 2:药师, 3:主管药师, 4:副主任药师, 5:主任药师)
     */
    @Column(name = "title_id")
    private Integer titleId;

    /**
     * 签名图片文件路径
     */
    @Column(name = "seal_image")
    private String sealImage;

    /**
     * 登陆密码
     */
    @Column(name = "password")
    private String password;

    /**
     * 密码盐
     */
    @Column(name = "salt")
    private String salt;
    /**
     * 登陆token
     */
    @Column(name = "token")
    private String token;

    /**
     * 账号状态(0/默认正常，1/禁用)_暂时不用
     */
    @Column(name = "account_status")
    private Integer accountStatus;

    /**
     * 用户状态(0:未注册, 1:已注册)
     */
    @Column(name = "status")
    private Integer status;

    /**
     * CA认证状态(0:待认证, 1:通过, 2:不通过)
     */
    @Column(name = "auth_status")
    private Integer authStatus;

    /**
     * 资格证地址
     */
    @Column(name = "license_url")
    private String licenseUrl;

    /**
     * 身份证正面照
     */
    @Column(name = "front_url")
    private String frontUrl;

    /**
     * 身份证反面照
     */
    @Column(name = "back_url")
    private String backUrl;

    @Column(name = "license_date")
    private Date licenseDate;

    /**
     * 创建时间
     */
    @Column(name = "created_at")
    private Date createdAt;

    /**
     * 创建人
     */
    @Column(name = "created_by")
    private String createdBy;

    /**
     * 修改人
     */
    @Column(name = "changed_by")
    private String changedBy;

    /**
     * 修改时间
     */
    @Column(name = "changed_at")
    private Date changedAt;

    /**
     * 最后修改密码时间
     */
    @Column(name = "last_pwd_modify")
    private Date lastPwdModify;

    /**
     * 乐观锁
     */
    @Version
    @Column(name = "version")
    private Integer version;


    /**
     * 获取患者性别
     * Patient.getGenderStr()
     *
     * @return
     *
     * @Date 2016年6月21日
     * @since 2.5.0
     */
    @Transient
    public String getGenderStr() {
        if (null == gender) {
            return "未知";
        }
        String genderStr;
        switch (gender) {
            case GENDER_FEMALE:
                genderStr = "女";
                break;
            case GENDER_MALE:
                genderStr = "男";
                break;
            case GENDER_UNKNOWN:
                genderStr = "未知";
                break;
            default:
                genderStr = "未知";
                break;
        }
        return genderStr;
    }

}
